<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="app" uri="http://www.wanrenhui.com" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
	  <%@include file="/res/include/base-head.jsp"%>
	  <%@include file="/res/include/jquery-easyui.jsp"%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/res/js/mall/mallOrder.js"></script>
  </head>
  <body>
	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false,split:false">
	    	<form id="query-form" class="search_form clearfix">
	    		<input id="shopId" name="shopId" type="hidden" value="${shopId}"/>
	            <dl>
					<dt>订单号：</dt>
					<dd>
						<input name="orderNo" id="orderNo" type="text" class="txt" maxlength="16"/>
					</dd>
				</dl>
				<dl>
	                <dt>业务类型：</dt>
	                <dd>
	                	<select name="orderType" id="orderType" class="txt">
	                		<option value="">--请选择--</option>
	                		<option value="1">家政</option>
	                		<option value="2">圈商</option>
	                		<option value="3">闲置品</option>
	                		<option value="4">活动</option>
	                		<option value="5">代收代送</option>
	                		<option value="6">圈商</option>
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	                <dt>订单状态：</dt>
	                <dd>
	                	<select name="orderStatus"  id="orderStatus" class="txt">
	                		<option value="">--请选择--</option>
	                		<option value="1">未完成</option>
	                		<option value="2">已完成</option>
	                		<option value="3">已取消</option>
	                		<option value="4">已删除</option>
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	                <dt>支付状态：</dt>
	                <dd>
	                	<select name="payStatus" id="payStatus" class="txt">
	                		<option value="">--请选择--</option>
	                		<option value="1">未付款</option>
	                		<option value="2">已付款</option>
	                		<option value="3">退款中</option>
	                		<option value="4">已退款</option>
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	                <dt>发货状态：</dt>
	                <dd>
	                	<select name="deliveryStatus" id="deliveryStatus" class="txt">
	                		<option value="">--请选择--</option>
	                		<option value="1">未发货</option>
	                		<option value="2">已发货</option>
	                		<option value="3">已签收</option>
	                	</select>
	                </dd>
	            </dl>
	            <dl>
	            	<dt>下单时间：从</dt>
	                <dd>
		                <input name="startAtStr" id="startAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/> 到 
		                <input name="endAtStr" id="endAtStr" type="text" class="txt easyui-datetimebox" maxlength="19"/>
	                </dd>
	            </dl>
	            <p class="search_form_btn">
	            	<input type="button" value="搜索" class="icon_serach" onclick="admin.mallOrder.query()" />
	            </p>
	        </form>
	        <form id="show-form" class="search_form clearfix">
		  		<dl>
					<dt>订单合计总额（元）：</dt>
					<dd id="sumTotal" name ="sumTotal">${sumTotal}</dd>
				</dl>
			</form>
	  	</div>
	    <div data-options="region:'center',border:false">
		    <table id="datagrid" data-options="url:'${pageContext.request.contextPath}/mall/order/list?shopId=${shopId }',toolbar:'#toolbar'">
				<thead>
					<tr>
						<th data-options="field:'orderNo',width:200,align:'center'">订单号</th>
						<th data-options="field:'title',width:200,align:'center'">产品简介</th>
						<th data-options="field:'orderType',width:100,align:'center',formatter:formatOrderType">业务类型</th>
						<th data-options="field:'buyerNick',width:80,align:'center'">买方昵称</th>
						<th data-options="field:'total',width:80,align:'center'">订单总额</th>
						<th data-options="field:'strNewAt',width:150,align:'center'">下单时间</th>
						<th data-options="field:'payStatus',width:100,align:'center',formatter:formatPayStatus">支付状态</th>
						<th data-options="field:'deliveryStatus',width:100,align:'center',formatter:formatDeliveryStatus">收发货状态</th>
						<th data-options="field:'orderStatus',width:100,align:'center',formatter:formatOrderStatus">订单状态</th>
			            <th data-options="field:'id',align:'center',width:150,formatter:formatOperation">操作</th>
					</tr>
				</thead>
			</table>
	  	</div>
	</div>

	<script>
		function formatOrderType(value,row,index) {
			var l_html = '家政';
			if (value==2) {
				l_html = '圈商';
			} else if (value==3) {
				l_html = '闲置品';
			} else if (value==4) {
				l_html = '活动';
			} else if (value==5) {
				l_html = '代收代送';
			} else if (value==6) {
				l_html = '圈商';
			}
			return l_html;
		}
		function formatPayStatus(value,row,index) {
			var l_html = '未付款';
			if (value==2) {
				l_html = '已付款';
			} else if (value==3) {
				l_html = '退款中';
			} else if (value==4) {
				l_html = '已退款';
			}
			return l_html;
		}
		function formatDeliveryStatus(value,row,index) {
			var l_html = '未发货';
			if (value==2) {
				l_html = '商家已发货';
			} else if (value==3) {
				if (row.deliveryStatusSignType == 3) {
					l_html = '配送人已签收';
				} else if(row.deliveryStatusSignType == 2) {
					l_html = '自动签收';
				} else {
					l_html = '买家已签收';
				}
			}
			return l_html;
		}
		function formatOrderStatus(value,row,index) {
			var l_html = '未完成';
			if (value==2) {
				l_html = '已完成';
			} else if (value==3) {
				l_html = '已取消';
			} else if (value==3) {
				l_html = '已删除';
			}
			return l_html;
		}
		function formatOperation(value,row,index) {
			var l_html = '';
			l_html += '<a href="javascript:;" class="table_link" onclick="admin.mallOrder.detail('+row.id+')">查看</a>';
			if(row.orderStatus == 1){
				l_html += '<a href="javascript:;" class="table_link" onclick="admin.mallOrder.cancel('+row.id+')">取消订单</a>';
			}
			if (row.payStatus == 2 && row.deliveryStatus == 1) { //已付款 未发货
				l_html += '|<a href="javascript:;" class="table_link" onclick="admin.mallOrder.toSend('+row.id+')">发货</a>';
			}
			return l_html;
		}
	</script>
  </body>
</html>
